<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <span style="display:block;padding:0;border:1px solid black;line-height: 14px">我Aa</span>
    <script type="application/javascript">
        /*add(1)(2)(3) = 6
        add(1, 2, 3)(4) = 10
        add(1)(2)(3)(4)(5) = 15*/


        let add = function () {

            let array = [];
            let length = arguments.length;
            for(let i=0;i<length;i++){
                array.push(arguments[i]);
            }

            let fn = function () {
                let length = arguments.length;
                for(let i=0;i<length;i++){
                    array.push(arguments[i]);
                }
                if (array.length)
                return fn;
            };

            fn.toString=function () {
                let sum = 0 ;
                array.forEach(function (item,index) {
                    sum+=Number.parseInt(item);
                })
                return sum;
            }

            return fn
        };

        console.log(add(1,2)(3)(4)(5)==15)

        console.log(add(1)(2)(3)==6)


    </script>
</body>
</html>